﻿using Entitys.Models.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace Common.Result
{
    public interface IResult<in TContent>
    {
        public abstract bool Result { get; }
    }

    public class ZResult<TContent> : IResult<TContent>
    {
        protected TContent? _content;

        internal TContent? Content { set { _content = value; } }

        internal ErrorEnumeration? ErrorEnumeration { get; set; }


        public bool Result { get; protected set; }

        public ZResult() : this(true)
        {
            this.ErrorEnumeration = CommonErrorEnumeration.Success;
        }
        public ZResult(bool result)
        {
            this.Result = result;
        }

        public ZResult(TContent? content) : this(true)
        {
            this.Content = content;
            this.ErrorEnumeration = CommonErrorEnumeration.Success;
        }

        public ZResult(ErrorEnumeration errorEnumeration) : this(false)
        {
            this.Content = default;
            this.ErrorEnumeration = errorEnumeration;
        }

        //public ZResult<TContent> ThrowError(
        //    [CallerFilePath] string sourceFilePath = ""
        //    , [CallerMemberName] string memberName = ""
        //    , [CallerLineNumber] int sourceLineNumber = 0)
        //{

        //}
    }

    public class ZResult : ZResult<object>
    {
        public static ZResult SuccessResult = new ZResult();

        public static ZResult Success()
        {
            return SuccessResult;
        }

        public static ZResult<TResultContent> Success<TResultContent>(TResultContent content)
        {
            return new ZResult<TResultContent>(content);
        }

        // public static ZResult Error(ErrorEnumeration errorEnumeration, params string[] msg)
        // {

        // }

    }
}
